<template>
  <div>
    <div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>
    <div>
       随叫随到；酒店专门配送
    </div>

    </div>
    <!-- 付款 的页面 -->
    <van-address-edit
      show-delete
      show-detail
      :show-area="false"
      save-button-text="确认付款"
      delete-button-text="取消付款"
      @save="onSave"
      @delete="onDelete"
    />
  </div>
</template>

<script>
import { Toast } from 'vant'
import { addIncomePay } from '@/api/income.js'
import { getItem } from '@/utils/localStorage.js'
import { updateGoodsList } from '@/api/goods.js'
export default {
  data() {
    return {
    }
  },
  methods: {
    async  onSave() {
      const income = await getItem('totalPrice')
      await addIncomePay({ // 发起 收入支出的请求
        income: income / 100,
        info: '零食饮料增加酒店收入'
      })

      // 发起 修改库存的请求
      const bb = await getItem('drinkInfoArr')
      const aa = await getItem('breadInfoArr')
      // 已经得到 修改库存接口 所需要的参数体了  是一个数组  [...aa, ...bb]
      var updateGoodsArr = [...aa, ...bb]
      updateGoodsArr.forEach(async item => {
        await updateGoodsList(item) // 遍历数组 挨个循环发送请求
      })
      console.log('修改商品库存成功')

      Toast.loading({
        message: '指纹支付中...',
        forbidClick: true
      })
      setTimeout(() => {
        Toast.loading({
          message: '付款成功',
          duration: 1000,
          icon: 'https://s.aigei.com/src/img/png/9b/9b4004f33a974023adaa9846960c389b.png?imageMogr2/auto-orient/thumbnail/!199x199r/gravity/Center/crop/199x199/quality/85/&e=1735488000&token=P7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL:fEmvKTQmAeWYRMFzXetbnwNt-ws=',
          forbidClick: true
        })
        this.$router.back()
      }, 2000)
    },
    onDelete(content) {
      this.$router.back()
    }
  }
}
</script>

<style>

</style>
